
Last chance! 50% off unlimited learning
Sale ends in
Add, remove and rename nodes in a graph.
# add and remove nodes.
add.node(x, node)
remove.node(x, node)# re-label nodes.
rename.nodes(x, names)
# S4 method for bn
nodes(object) <- value
# S4 method for bn.fit
nodes(object) <- value
add.node()
, remove.node()
and rename.nodes()
return an
updated bn
object.
an object of class bn
for add.node()
and
remove.node()
; an object of class bn
or bn.fit
for
rename.nodes()
.
an object of class bn
or bn.fit
.
a character string, the label of a node.
a vector of character strings, the new set of labels that wll be used as to rename the nodes.
Marco Scutari
add.node()
adds a new (isolated) node to an existing bn
object.
remove.node()
removes a node from a bn
object.
rename.nodes()
replaces the node labels with new ones, relabelling the
whole node set. The assignment method for nodes()
is an alias of
rename.nodes()
.
dag = random.graph(LETTERS[1:5])
add.node(dag, "Z")
remove.node(dag, "A")
nodes(dag)
nodes(dag) = LETTERS[6:10]
nodes(dag)
Run the code above in your browser using DataLab